package com.wuchao.servlet143;

import com.wuchao.entity.Pojo;
import com.wuchao.service.serviceimpl.ServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 吴超66
 * @version 1.0
 * @date 2022/4/24 16:41
 */
@WebServlet(name = "Servlet1",urlPatterns = "/Servlet1")
public class Servlet1 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out=response.getWriter();//文件流
        List<String> xx=new ArrayList<>();
        ServiceImpl service = new ServiceImpl();
        List<Pojo> poJo = service.findPoJo("select * from t143");

        xx.add("xjj");
        request.setAttribute("list",xx);
        request.setAttribute("list1",poJo);
        request.getRequestDispatcher("/demo71/EL.jsp").forward(request,response);

        out.flush();
        out.close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out=response.getWriter();//文件流
        List<String> xx=new ArrayList<>();
        ServiceImpl service = new ServiceImpl();
        List<Pojo> poJo = service.findPoJo("select * from t143");

        xx.add("xjj");
        request.setAttribute("list",xx);
        request.setAttribute("list1",poJo);
        request.getRequestDispatcher("/demo71/EL.jsp").forward(request,response);;

        out.flush();
        out.close();
    }
}
